package com.prd.controller;

import com.prd.model.EntNarration;
import com.prd.model.EntNarrationCase;
import com.prd.service.EntNarrationService;
import com.prd.util.AjaxResult;
import com.prd.util.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = {"述职管理"})
@RestController
@RequestMapping("/api/entNarration")
public class EntNarrationController extends BaseController {

    @Autowired
    private EntNarrationService entNarrationService;

    @ApiOperation("查询列表")
    @GetMapping("list")
    public TableDataInfo list(@ApiParam("日期") String day, @ApiParam("1：我发起、2：我接受、3：草稿、4：待面谈、5：已面谈、6：执行中") Integer catalog) {
        startPage();
        List<EntNarration> list = entNarrationService.listInfo(day, catalog);
        return getDataPage(list);
    }

    @ApiOperation("添加信息")
    @PostMapping("add")
    public AjaxResult add(@RequestBody EntNarration entNarration) {
        return toAjax(entNarrationService.saveOrUpdateInfo(entNarration, true));
    }

    @ApiOperation("修改信息")
    @PostMapping("update")
    public AjaxResult update(@RequestBody EntNarration entNarration) {
        return toAjax(entNarrationService.saveOrUpdateInfo(entNarration, false));
    }

    @ApiOperation("查询详情")
    @GetMapping("details/{id}")
    public AjaxResult details(@ApiParam("述职ID") @PathVariable("id") Long id) {
        return AjaxResult.success(entNarrationService.details(id));
    }

    @ApiOperation("查询详情记录/纪要")
    @GetMapping("detailsRecord/{interviewId}")
    public AjaxResult detailsRecord(@ApiParam("面谈ID") @PathVariable("interviewId") Long interviewId) {
        return AjaxResult.success(entNarrationService.detailsRecord(interviewId));
    }

    @ApiOperation("提交报告")
    @PostMapping("submitReport/{id}")
    public AjaxResult submitReport(@PathVariable("id") Long id) {
        return toAjax(entNarrationService.submitReport(id));
    }

    @ApiOperation("增加抄送人")
    @PostMapping(value = "addMake/{id}/{makes}")
    public AjaxResult addMake(@ApiParam("述职ID") @PathVariable("id") Long id, @ApiParam("抄送人（多个,分开）") @PathVariable("makes") Long[] makes) {
        return toAjax(entNarrationService.addMake(id, makes));
    }

    @ApiOperation("添加面谈指导")
    @PostMapping("addGuidance")
    public AjaxResult submitReport(EntNarrationCase entNarrationCase) {
        return toAjax(entNarrationService.addGuidance(entNarrationCase));
    }
}
